using System;
using System.Collections.Generic;
using System.Linq;
namespace System.Windows.Controls
{
	public static class TemplatedVisualTreeExtensions
	{
		internal static T smethod_0<T>(this FrameworkElement frameworkElement_0, bool bool_0) where T : FrameworkElement
		{
			Queue<FrameworkElement> queue = new Queue<FrameworkElement>();
			queue.Enqueue(frameworkElement_0);
			while (queue.get_Count() > 0)
			{
				FrameworkElement frameworkElement = queue.Dequeue();
				Control control = frameworkElement as Control;
				if (bool_0 && control != null)
				{
					control.ApplyTemplate();
				}
				if (frameworkElement is T && frameworkElement != frameworkElement_0)
				{
					return (T)((object)frameworkElement);
				}
				using (IEnumerator<FrameworkElement> enumerator = Enumerable.OfType<FrameworkElement>(frameworkElement.smethod_0()).GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						FrameworkElement current = enumerator.get_Current();
						queue.Enqueue(current);
					}
				}
			}
			return default(T);
		}
		internal static IEnumerable<T> smethod_1<T>(this FrameworkElement frameworkElement_0, bool bool_0) where T : FrameworkElement
		{
			TemplatedVisualTreeExtensions.Class30<T> @class = new TemplatedVisualTreeExtensions.Class30<T>(-2);
			@class.frameworkElement_1 = frameworkElement_0;
			@class.bool_1 = bool_0;
			return @class;
		}
	}
}
